package cn.fintecher.pangolin.service.dataimp.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.Objects;

/**
 * @Auther: xiaqun
 * @Description: 委前催记查询请求参数
 * @Date: 9:15 2019/10/12
 */

@Data
public class FindPreRecordRequest {
    @ApiModelProperty(value = "批次号")
    private String batchNumber;

    @ApiModelProperty(value = "证件号")
    private String certificateNo;

    public BoolQueryBuilder getBuilder() {
        BoolQueryBuilder builder = new BoolQueryBuilder();
        builder.must(QueryBuilders.matchPhraseQuery("batchNumber.keyword", this.batchNumber));
        if (StringUtils.isNotBlank(this.certificateNo)) {
            builder.must(QueryBuilders.wildcardQuery("certificateNo.keyword", this.certificateNo));
        }
        return builder;
    }
}
